package com.paic.mario.web;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.paic.mario.service.SystemService;
import com.paic.mario.service.TempletService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;



@RestController
public class TempletController {
    
	
	@Autowired
	private TempletService templetService;
	
	@RequestMapping(value="/templet/saveAndloadTemplet",method=RequestMethod.POST) 
	public  List<Map<String, Object>> saveAndloadTemplet(@RequestParam(value="templet_id", required=true) int templet_id,@RequestBody List<Map> service_json_list){ 
		List<Map<String, Object>> reslutList = new ArrayList<Map<String, Object>>();
		String flag = "";
		//TEst
		reslutList = templetService.saveAndloadTemplet(templet_id,flag,service_json_list);

		return reslutList; 
	}

	
	
//    public static void main(String[] args) {
//
//    	List<Map>  list_map = new ArrayList<Map>();
//
//    	List<Map>  list_para = new ArrayList<Map>();
//    	Map map_para1 =new HashMap();
//    	map_para1.put("key_ena","frequency");    
//    	map_para1.put("key_cna","采集频率");    
//    	map_para1.put("defult_value","60");    
//    	map_para1.put("is_req","Y");    
//    	map_para1.put("tip","");  
//    	list_para.add(map_para1);
//    	Map map_para2 =new HashMap();
//    	map_para2.put("key_ena","cpu");    
//    	map_para2.put("key_cna","cpu");    
//    	map_para2.put("defult_value","false");    
//    	map_para2.put("is_req","Y");    
//    	map_para2.put("tip",""); 
//    	list_para.add(map_para2);
//    	Map map_para3 =new HashMap();
//    	map_para3.put("key_ena","mem");    
//    	map_para3.put("key_cna","mem");    
//    	map_para3.put("defult_value","false");    
//    	map_para3.put("is_req","Y");    
//    	map_para3.put("tip",""); 
//    	list_para.add(map_para3);
//    	Map map_para4 =new HashMap();
//    	map_para4.put("key_ena","kernel");    
//    	map_para4.put("key_cna","kernel");    
//    	map_para4.put("defult_value","false");    
//    	map_para4.put("is_req","Y");    
//    	map_para4.put("tip","");
//    	list_para.add(map_para4);
//    	
//    	
//    	Map map1 =new HashMap();
//    	map1.put("service_name","serviceName11");
//    	map1.put("service_id","122323");
//    	map1.put("templet_properties",list_para);
//    	map1.put("templet_id","13");
//    	list_map.add(map1);
//    	Map map2 =new HashMap();
//    	map2.put("service_name","serviceName22");
//    	map2.put("service_id","23421");
//    	map2.put("templet_properties",list_para);
//    	map2.put("templet_id","23");
//    	list_map.add(map2);
//    	
//    	JSONArray json_returnStr = JSONArray.fromObject(list_map);   
//        
//        System.out.println(json_returnStr);
//        
//    }
}
